# -*- coding: utf-8 -*-
# @Time    : 2022/11/1 16:53
# @Author  : yangyuexiong
# @Email   : yang6333yyx@126.com
# @File    : __init__.py.py
# @Software: PyCharm

import psutil
from pywinauto import Application


def f(path=None, proc_id=None):
    """

    :param path:
    :param proc_id:
    :return:
    """

    if path:
        print(f'path:{path}')
        app = Application(backend='uia').start(path)
        return app
    elif proc_id:
        print(f'proc_id:{proc_id}')
        app = Application(backend='uia').connect(process=proc_id)
        return app
    else:
        return False


def get_pid(name):
    for proc in psutil.process_iter():
        try:
            if proc.name() == name:
                return proc.pid
        except BaseException as e:
            print(str(e))

    return -1
